public class Solution {
    public int findComplement(int num) {
        return (num ^ Integer.MAX_VALUE) % (int) Math.pow(2, (int) (Math.log(Integer.highestOneBit(num)) / Math.log(2)));
    }
}
